package org.android.brasil.projetos.oktoberfest2011.utils;

import org.android.brasil.projetos.oktoberfest2011.R;
import org.android.brasil.projetos.oktoberfest2011.negocio.model.Apresentacao;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnLongClickListener;

public class CompartilhamentoListener {

	public CompartilhamentoListener(final Context ctx, View rl,
			final Apresentacao apr) {
		rl.setOnLongClickListener(new OnLongClickListener() {

			public boolean onLongClick(View v) {

				String frase = ctx.getResources().getString(
						R.string.eu_vou_assitir_)
						+ apr.getNome()
						+ ctx.getResources().getString(R.string._as_)
						+ DataUtil.formatarHora(apr.getHoraInicio())
						+ ctx.getResources().getString(R.string._no_)
						+ apr.getSetor()
						+ ctx.getResources().getString(R.string._no_dia_)
						+ apr.getDia() + Constantes.MES_E_ANO;
				
				if(apr.getCategoria() == Constantes.DESFILE){
					frase = ctx.getResources().getString(
							R.string.eu_vou_assitir_)
							+ apr.getNome()
							+ ctx.getResources().getString(R.string._as_)
							+ DataUtil.formatarHora(apr.getHoraInicio())
							+ apr.getSetor()
							+ ctx.getResources().getString(R.string._no_dia_)
							+ apr.getDia() + Constantes.MES_E_ANO;
				}
				frase = frase +" "+ Constantes.HASH_TAG;
				Intent sendIntent = new Intent(Intent.ACTION_SEND);
				sendIntent.putExtra(Intent.EXTRA_TEXT, frase);
				sendIntent.setType("text/plain");
				sendIntent.putExtra(Intent.EXTRA_SUBJECT, Constantes.HASH_TAG);
				Intent i = Intent
						.createChooser(sendIntent, ctx.getResources().getString(R.string.compartilhar_via));
				i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				ctx.startActivity(i);

				return true;
			}
		});
	}
}
